package com.zhangtai.modules.dao;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zhangtai.modules.entity.system.UserGroupEntity;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2020-08-11 08:59:02
 */
@Mapper
public interface UserGroupDao extends BaseMapper<UserGroupEntity> {

	@Delete("DELETE FROM sys_user_group WHERE user_id = #{userId}")
	public void deleteUserGroup(@Param("userId") Long userId);


	@Select("SELECT\n" +
			" org_id \n" +
			"FROM\n" +
			" sys_user_group T1\n" +
			" INNER JOIN sys_org_group T2 ON T1.group_id = T2.group_id \n" +
			"WHERE\n" +
			" user_id = #{userId}")
	public List<String> getUserOrgById(@Param("userId") Long userId);


}
